package com.snail.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snail.mapper.BizWorksMapper;
import com.snail.model.pojo.media.BizContentReview;
import com.snail.model.pojo.media.BizWorks;
import com.snail.model.query.media.ContentReviewQuery;
import com.snail.service.BizContentReviewService;
import com.snail.mapper.BizContentReviewMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author Monica
 * @description 针对表【biz_content_review(内容审核记录表)】的数据库操作Service实现
 * @createDate 2025-08-20 16:34:34
 */
@Service
public class BizContentReviewServiceImpl extends ServiceImpl<BizContentReviewMapper, BizContentReview> implements BizContentReviewService {

    @Autowired
    private BizContentReviewMapper bizContentReviewMapper;
    @Autowired
    private BizWorksMapper bizWorksMapper;

    @Override
    public Boolean review(ContentReviewQuery review) {
        Long worksId = review.getWorksId();
        LambdaQueryWrapper<BizContentReview> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BizContentReview::getContentId, worksId);
        BizContentReview bizContentReview = bizContentReviewMapper.selectOne(queryWrapper);
        bizContentReview.setManualReviewerId(review.getManualReviewerId());
        bizContentReview.setManualReviewRemark(review.getManualReviewRemark());
        bizContentReview.setManualReviewTime(LocalDateTime.now());
        bizContentReview.setReviewType(1);


        BizWorks works = bizWorksMapper.selectById(worksId);
        if (review.getReviewStatus() == 0) {
            works.setStatus(3);
            bizContentReview.setReviewStatus(0);
        } else {
            works.setStatus(5);
            bizContentReview.setReviewStatus(2);
        }
        bizWorksMapper.updateById(works);
        bizContentReviewMapper.updateById(bizContentReview);
        return true;
    }
}




